use anyhow::bail;
use dirs::home_dir;
use std::{fs::File, io::Read};

const LOCAL_PATH: &str = ".config/helix/languages.toml";

pub fn local_str() -> anyhow::Result<String> {
    let home = match home_dir() {
        Some(path) => path,
        None => bail!("没有找到家目录"),
    };
    let path = home.join(LOCAL_PATH);
    let mut file = File::open(path)?;
    let mut buffer = String::default();
    file.read_to_string(&mut buffer)?;
    Ok(buffer)
}
